package com.example.user.coolrun.runnershign;

import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;

import com.example.user.coolrun.R;

import java.util.ArrayList;
import java.util.List;

public class ShopActivity extends AppCompatActivity {

    private DrawerLayout mDrawerLayout;


    private People[] people = {new People("小强强", R.drawable.xiaoqiangqiang), new People("黑头强", R.drawable.heitouqiang),
            new People("光头强", R.drawable.guangtouqiang), new People("真的强", R.drawable.zhendeqiang), new People("铁头强", R.drawable.tietouqiang)};

    private List<People> peopleList = new ArrayList<>();

    private PeopleAdapter adapter;

    public ShopActivity() {
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        //隐藏状态栏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        setContentView(R.layout.activity_shop);
        ImageButton back = (ImageButton)findViewById(R.id.imageButton);



        initPeoples();
        RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycle_view);
        GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
        recyclerView.setLayoutManager(layoutManager);
        PeopleAdapter adapter = new PeopleAdapter(peopleList);
        recyclerView.setAdapter(adapter);

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initPeoples() {
        for (int i = 0; i < people.length; i++){
            peopleList.add(people[i]);
        }
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            finish();
            overridePendingTransition(R.anim.enter_zoom_in,R.anim.enter_zoom_out);
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

}


